import ajax from "./ajax";
import mockAjax from "./mockAjax";

// 专门用来请求三级分类的
export const reqCategoryList = () =>
  ajax({ url: "/product/getBaseCategoryList", method: "get" });
// 专门用来请求banner数据的
export const reqBannerList = () => mockAjax({ url: "/banner", method: "get" });
// 专门用来请求floor数据的
export const reqFloorList = () => mockAjax({ url: "/floor", method: "get" });
// 专门用来搜索商品的
export const reqGoodsInfo = (searchParams) =>
  ajax({ url: "/list", method: "post", data: searchParams });
// 专门用来请求商品详情的
export const reqGoodsDetail = (skuId) =>
  ajax({ url: `/item/${skuId}`, method: "get" });
// 专门用来添加购物车(还可以对购物车已有数量进行修改)
export const reqAddShopcart = (skuId, skuNum) =>
  ajax({ url: `/cart/addToCart/${skuId}/${skuNum}`, method: "post" });
// 专门用来请求购物车列表
export const reqShopcartList = () =>
  ajax({ url: "/cart/cartList", method: "get" });
// 专门用来请求更改单个选中状态
export const reqChangeOneChecked = (skuId, isChecked) =>
  ajax({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: "get" });
// 专门用来请求更改多个选中状态
export const reqChangeAllChecked = (isChecked, skuIdList) =>
  ajax({
    url: `/cart/batchCheckCart/${isChecked}`,
    method: "post",
    data: skuIdList,
  });
// 专门用来请求删除单个商品
export const reqDeleteOne = (skuId) =>
  ajax({ url: `/cart/deleteCart/${skuId}`, method: "delete" });
// 专门用来请求删除选中商品
export const reqDeleteChecked = (skuIdList) =>
  ajax({ url: "/cart/batchDeleteCart", method: "post", data: skuIdList });
// 专门用来请求获取验证码
export const reqCode = (phone) =>
  ajax({ url: `/user/passport/sendCode/${phone}`, method: "get" });
// 专门用来请求注册用户的
export const reqRegisterUser = (paramsObj) =>
  ajax({ url: "/user/passport/register", method: "post", data: paramsObj });
// 专门用来请求用户登录的
export const reqLogin = (paramsObj) =>
  ajax({ url: "/user/passport/login", method: "post", data: paramsObj });
// 专门用来请求用户信息的
export const reqUserInfo = () =>
  ajax({ url: "/user/passport/auth/getUserInfo", method: "get" });
// 专门用来请求退出登录的
export const reqLogout = () =>
  ajax({ url: "/user/passport/logout", method: "get" });
// 专门用来请求用户地址的
export const reqUserAddressList = () =>
  ajax({ url: "/user/userAddress/auth/findUserAddressList", method: "get" });
// 专门用来请求交易信息的
export const reqTradeInfo = () =>
  ajax({ url: "/order/auth/trade", method: "get" });
// 专门用来请求提交订单的
export const reqSubmitOrder = (tradeNo, orderParams) =>
  ajax({
    url: `/order/auth/submitOrder?tradeNo=${tradeNo}`,
    method: "post",
    data: orderParams,
  });
// 专门用来请求支付信息的
export const reqPayInfo = (orderId) =>
  ajax({ url: `/payment/weixin/createNative/${orderId}`, method: "get" });
